<?php
$messageList = array();
$eventId = $parentEventId;
if ($eventId > 0) {
    $event = new BWEvent($eventId);
    $messageList = $event->getMessageManager()->getMessageList();
}
//Blyn::app()->getUIManager()->getCurrentScreen()->addContextVariable('eventId', $eventId); 
?>
<?php
$form = $this->beginWidget('CActiveForm', array(
    "id" => "message-form",
    'enableAjaxValidation' => FALSE,
    'htmlOptions' => array('enctype' => 'multipart/form-data'),
        ));
?>
<div class="modal-body" id="Event_shop_add">
    <div><legend style="margin-bottom: 0px;">
        <?php echo $control->getAjaxLink(array('name' => '活动列表', 'id' => 'showEventList'), array('htmlOptions' => array('enctype' => 'multipart/form-data')));?> &gt; 
        <?php echo $control->getAjaxLink(array('name' => $event->name.'商品列表', 'id' => 'showMessageList'), array('parentEventId'=>$eventId,'htmlOptions' => array('enctype' => 'multipart/form-data')));?>
        </legend>
    </div>
    <fieldset>
        <table class="table table-hover">
            <thead>
                <tr>
                    <th>
                        <input type="checkbox" id="ShopCheckAll"> 
                    </th>
                    <th>商品名称</th>
    <!--                <th>数量</th>-->
                    <th>商品价格</th>
    <!--                <th>状态</th>-->
                    <th>行动</th>
                </tr> 
            </thead>
            <tbody>

                <?php
                foreach ($messageList as $message) {
                    ?>
                    <tr>
                        <td><label class="checkbox">
                                <input type="checkbox" name="subBox" value="1"> 
                            </label></td>
                        <td> <?php echo $message->name; ?>  </td>
                        <td> <?php echo $message->getMediaManager()->getMedia('price')->content; ?></td>
                        <td>
                            <a href="#myModal<?php echo $message->id;?>" role="button" data-toggle="modal">修改</a>
                 
                            <?php
                            $modalPage = new BUIControl();
                            $modalPage->addRenderView('modalPage', 'addMessage', array('messageId'=>$message->id,'eventId' => $eventId,'form'=>$form));
                            $modalPage->render();
                            ?>
                        </td>
                    </tr>
                <?php } ?>             
            </tbody>
        </table>

        <div class="row-fluid">
            <?php //echo $control->getAjaxLink(array('name' => '添加商品', 'id' => 'addMessage'), array('htmlOptions' => array('enctype' => 'multipart/form-data', 'class' => 'btn'))); ?>
            <a href="#myModal0" role="button" data-toggle="modal" class="btn">添加商品</a>
            <a href="#" role="button" data-toggle="modal" class="btn">删除商品</a>
        </div>
        <?php
        $modalPage = new BUIControl();
        $modalPage->addRenderView('modalPage', 'addMessage', array('messageId'=>0,'eventId' => $eventId,'form'=>$form));
        $modalPage->render();
        ?>
    </fieldset>
</div> 
<?php $this->endWidget(); ?>